package com.bluejie.springBoot.controller;

import com.bluejie.springBoot.entity.Demo;
import com.bluejie.springBoot.entity.rpc.RequestData;
import com.bluejie.springBoot.tools.LogUtil;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by bluej on 2018-03-11.
 */
@RestController
@RequestMapping("/test")
public class TestController {
    Logger log = LogUtil.getLog(TestController.class);
    @Autowired
    private Demo demo;

    @ModelAttribute("requestData")
    public RequestData initData(RequestData requestData){

        if (requestData==null){
            requestData = new RequestData();
        }
        return requestData;
    }
    @RequestMapping("/hello")
    public String helloWord(RequestData requestData){
        System.out.println("--say:"+requestData.getSay()+"--");
        return "hello word !";
    }

    @RequestMapping("/demo")
    public Demo demo(){
        log.info("demo()");
        return demo;
    }
}
